home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UCRASM25.ARJ / PUTL.ASM < prev    next >
Assembly Source File  |  1991-11-14  |  1KB  |  84 lines

  1. StdGrp        group    stdlib,stddata
  2. stddata        segment    para public 'sldata'
  3. stddata        ends
  4. ;
  5. stdlib        segment    para public 'slcode'
  6.         assume    cs:stdgrp
  7.         extrn    sl_putc:far
  8. ;
  9. ; Putl prints the value in DX:AX as a signed dword integer value.
  10. ;
  11.         public    sl_putl
  12. sl_Putl        proc    far
  13.         push    ax
  14.         push    bx
  15.         cmp    dx, 0
  16.         jge    Doit
  17.         push    ax
  18.         mov    al, '-'
  19.         call    sl_Putc
  20.         pop    ax
  21.         neg    dx
  22.         neg    ax
  23.         sbb    dx, 0
  24. ;
  25. DoIt:        call    puti2
  26.         pop    dx
  27.         pop    ax
  28.         ret
  29. sl_Putl        endp
  30. ;
  31. ; Putul prints the value in DX:AX as an unsigned dword integer value.
  32. ;
  33.         public    sl_PutUL
  34. sl_PutUL    proc    far
  35.         push    ax
  36.         push    dx
  37.         call    PutI2
  38.         pop    dx
  39.         pop    ax
  40.         ret
  41. sl_PutUL    endp
  42. ;
  43. ; Puti2- Iterative routine to print a 32-bit unsigned value.
  44. ;     This code was suggested by terge m and david holm.
  45. ;
  46. Puti2        proc
  47.         push    bx
  48.         push    cx
  49.         push    di
  50.         mov    bx, dx
  51.         mov    di, 10
  52.         xor    cx, cx
  53.         jmp    TestBX
  54. ;
  55. Puti2Lp32:    xchg    ax, bx
  56.         xor    dx, dx
  57.         div    di
  58.         xchg    ax, bx
  59.         div    di
  60.         add    dl, '0'
  61.         push    dx
  62.         inc    cx
  63. TestBX:        or    bx, bx
  64.         jnz    Puti2Lp32
  65. ;
  66. Puti2Lp2:    xor    dx, dx
  67.         div    di
  68.         add    dl, '0'
  69.         push    dx
  70.         inc    cx
  71.         or    ax, ax
  72.         jnz    Puti2Lp2
  73. ;
  74. PrintEm:    pop    ax
  75.         call    sl_putc
  76.         loop    PrintEm
  77.         pop    di
  78.         pop    cx
  79.         pop    bx
  80.         ret
  81. Puti2        endp
  82. stdlib        ends
  83.         end
  84.